package com.crealth.db;

import org.apache.log4j.Logger;
import com.crealth.manager.MybatisManager;
import com.crealth.model.PledgeDiYaModel;

public class PledgeDiYaDb {
	private static Logger errorLog = Logger.getLogger("error_log");

	public static Integer insertPledgeDiYa(PledgeDiYaModel diyaModel) {
		Integer res = null;
		try {
			res = MybatisManager.diyaMapper.insertPledgeDiYa(diyaModel);
			MybatisManager.commit();
		} catch (Exception e) {
			errorLog.error("insertPledgeDiYa", e);
		}
		return res;
	}
	
	public static PledgeDiYaModel selectPledgeDiYaByProductID(int productID) {
		PledgeDiYaModel diya = MybatisManager.diyaMapper.selectPledgeDiYaByProductID(productID);
		return diya;
	}
	
	public static Integer selectPledgeDiYaIDByProductID(int productID) {
		Integer res = MybatisManager.diyaMapper.selectPledgeDiYaIDByProductID(productID);
		return res;
	}
	
	public static Integer updatePledgeDiYaByID(PledgeDiYaModel diyaModel) {
		Integer res = null;
		try {
			res = MybatisManager.diyaMapper.updatePledgeDiYaByID(diyaModel);
		} catch (Exception e) {
			errorLog.error("updatePledgeDiYaByID", e);
		}
		MybatisManager.commit();
		
		return res;
	}
	
}
